{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Markdown\n",
    "Markdown is a lightweight markup language for creating formatted text using a plain-text editor.<br>\n",
    "Markdown 是一种轻量级标记语言，用于使用纯文本编辑器创建格式化文本。\n",
    "\n",
    "This covers how to load Markdown documents into a document format that we can use downstream.<br>\n",
    "这涵盖了如何将文档加载 Markdown 为我们可以在下游使用的文档格式。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[Document(page_content='Markdown Documents\\n\\n1. Introduction\\n\\nThis is a markdown document.\\n\\n2. Installation\\n\\ndocs = loader.load()', metadata={'source': '../data/README.md'})]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from langchain_community.document_loaders import UnstructuredMarkdownLoader\n",
    "\n",
    "markdown_path = \"../data/README.md\"\n",
    "loader = UnstructuredMarkdownLoader(markdown_path)\n",
    "loader.load()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[Document(page_content='Markdown Documents', metadata={'source': '../data/README.md', 'category_depth': 0, 'last_modified': '2024-07-26T11:42:48', 'languages': ['eng'], 'filetype': 'text/markdown', 'file_directory': '../data', 'filename': 'README.md', 'category': 'Title'}),\n",
       " Document(page_content='1. Introduction', metadata={'source': '../data/README.md', 'category_depth': 1, 'last_modified': '2024-07-26T11:42:48', 'languages': ['eng'], 'parent_id': '1c3b35bc80c33f0b14828598c7848d41', 'filetype': 'text/markdown', 'file_directory': '../data', 'filename': 'README.md', 'category': 'Title'}),\n",
       " Document(page_content='This is a markdown document.', metadata={'source': '../data/README.md', 'last_modified': '2024-07-26T11:42:48', 'languages': ['eng'], 'parent_id': '5f9426bbb3164a467400a9410fa5363d', 'filetype': 'text/markdown', 'file_directory': '../data', 'filename': 'README.md', 'category': 'NarrativeText'}),\n",
       " Document(page_content='2. Installation', metadata={'source': '../data/README.md', 'category_depth': 1, 'last_modified': '2024-07-26T11:42:48', 'languages': ['eng'], 'parent_id': '1c3b35bc80c33f0b14828598c7848d41', 'filetype': 'text/markdown', 'file_directory': '../data', 'filename': 'README.md', 'category': 'Title'}),\n",
       " Document(page_content='docs = loader.load()', metadata={'source': '../data/README.md', 'category_depth': 0, 'last_modified': '2024-07-26T11:42:48', 'languages': ['eng'], 'filetype': 'text/markdown', 'file_directory': '../data', 'filename': 'README.md', 'category': 'Title'})]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "loader = UnstructuredMarkdownLoader(markdown_path, mode=\"elements\")\n",
    "loader.load()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "langchain0_1",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
